package booking.utils;

import java.util.ArrayList;
import java.util.List;

import com.cjw.model.DBMap;
import com.moomi.common.model.BkBooking;
import com.utils.Utils;

public class BookedUtils extends BKUtils {

	public BookedUtils(int shopId) {
		super(shopId);
	}

	public ArrayList<DBMap> getBookedItems(int page, String bookDate, Integer selectionId) {
		if (page < 1) {
			page = 1;
		}
		ArrayList<DBMap> array = new ArrayList<>();
		// List<BkBooking> items = BkBooking.dao.search("shopId", shop.getId());
		if (bookDate == null) {
			bookDate = Utils.dateNow("yyyy-MM-dd");
		}
		List<BkBooking> items = BkBooking.dao.getBookingInfo(shop.getId(), null, selectionId, bookDate);
		double timeNow = Utils.systemTime();
		for (BkBooking bkBooking : items) {
			DBMap map = new DBMap();

			// boolean isPass = timeNow > bkBooking.getBookTimeDouble();
			// if (isPass) {
			// if (BookingUtils.hideTimeOutBookingInfo) {
			// continue;
			// }
			// map.put("passed", isPass);
			// }
			map.put("item", bkBooking);
			map.put("id", bkBooking.getId());
			map.put("time", timeUtil.timeIndexToString(bkBooking.getBookTime()));
			array.add(map);
		}
		return array;
	}

	public ArrayList<DBMap> getBookedItems(int page, String bookDate) {
		return getBookedItems(page, bookDate, null);
	}
}
